﻿using CMS.Enbities;
using CMS.Models;
using GalaSoft.MvvmLight;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Security;

namespace CMS
{
    //ObservableObject 这个也继承了INotp...接口通知属性更改
    public class AppData : ObservableObject
    {
        public AppData() 
        {
            roles.Add(new Role() { Name = "管理员", Id = 0 });
            roles.Add(new Role() { Name = "操作员", Id = 1 });
            roles.Add(new Role() { Name = "挂壁员", Id = 2 });
            roles.Add(new Role() { Name = "打工人", Id = 3 });
        }
        //Lazy延迟初始化 
        public static AppData Instance = new Lazy<AppData>(()=>new AppData()).Value;

        public string systemName = "仓库物资管理系统2.0";
        public string SystemName
        {
            get { return systemName; }
            set { systemName = value; RaisePropertyChanged(nameof(SystemName)); }
        }
        //当前用户
        private Menber menber = new Menber();
        public Menber CurrentUser
        {
            get { return menber; }
            set { menber = value; RaisePropertyChanged(nameof(CurrentUser)); }
        }
        /// <summary>
        /// 主窗体
        /// </summary>
        public MainWindow MainWindow { get; set; } = null;
        /// <summary>
        /// 显示或隐藏遮罩层
        /// </summary>
        /// <param name="isMark"></param>
        public void ShowMarkLayer(bool isMark)
        {
            if (MainWindow == null) return;
            MainWindow.markLayer.Visibility = isMark ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
                
            
        }
        /// <summary>
        /// 角色集合 Enbitis文件
        /// </summary>
       private List<Role> roles= new List<Role>();
        public List<Role> Roles
        {
            get { return roles; }
            set { roles = value; RaisePropertyChanged(nameof(Roles)); }
        }
    }
}
